<?php
/**
 * Created by HBuilder.
 * User: Ason
 * Date: 16-1-1
 * Time: 下午11:20
 */
?>
<div class="modal-dialog modal-lg">
	<div class="modal-content">

		<div class="modal-header bordered-bottom-3 bordered-orange">
			<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span
					class="sr-only">Close</span></button>
			<h4 class="modal-title"><span class="glyphicon glyphicon-pencil"></span>修改个人信息</h4>
		</div>
		<div class="modal-body">
			<!--错误提示 BEGIN-->
				<div id="edit_alert" class="alert text-center" style="display:none;"></div>
			<!--错误提示 END-->
			<form class="form">
				<div class="form-group clearfix form-bordered">
					<label class="control-label col-md-2">用户名</label>

					<div class="col-md-10">
						<div class="form-group">
							<input type="text" class="form-control" name="u_uid" id="u_uid" value="<?=$user->uid;?>" disabled>
						</div>
					</div>
				</div>
				<div class="form-group clearfix form-bordered">
					<label class="control-label col-md-2">姓名</label>

					<div class="col-md-10">
						<div class="form-group">
							<input type="text" class="form-control" name="u_name" id="u_name" value="<?=$user->name;?>">
						</div>
					</div>
				</div>
				
				<div class="form-group clearfix form-bordered">
					<label class="control-label col-md-2">性别</label>
					<div class="col-md-10">
						<div class="control-group">
                            <div class="radio">
                                <label>
                                    <input name="u_sex" type="radio" class="colored-blue" value="1" <?php if($user->sex) echo "checked";?>>
                                    <span class="text">男 </span>
                                </label>

                                <label>
                                    <input name="u_sex" type="radio" class="colored-danger" value="0" <?php if(!$user->sex) echo "checked";?>>
                                    <span class="text">女</span>
                                </label>
                            </div>
                        </div>
					</div>
				</div>

				<div class="form-group clearfix form-bordered">
					<label class="control-label col-md-2">Email</label>
					<div class="col-md-10">
						<div class="form-group">
							<input type="email" class="form-control" name="u_email" id="u_email" placeholder="电子邮件地址" value="<?=$user->email;?>">
						</div>
					</div>
				</div>
			</form>

		</div>
		<div class="modal-footer">
			<div class="form-group text-right">
				<button class="btn btn-success" id="save">确认修改</button>&nbsp;&nbsp;&nbsp;&nbsp;
				<button class="btn btn-default" data-dismiss="modal">取消</button>
			</div>
		</div>


	</div>
</div>
<script>
	$("#save").click(function(){
		$.post(
			"<?=site_url('user/do_edit_user') .'/'. $user->id;?>",
			{
				name:$('#u_name').val(),
				sex:$("input[name='u_sex']:checked").val(),
				email:$('#u_email').val(),
			},
			function( json ){
				$( '#edit_alert' ).removeClass( 'alert-danger show').text('');
				data = eval( '(' + json + ')' );
				if( data.status == 'error' ){
					$('#edit_alert' ).addClass('alert-danger show').text( data.error );
				}else{
					$('#edit_alert' ).addClass('alert-success show').text( data.error );
					setTimeout( function(){
						window.location.reload();
					}, 2000);
				}
			}
		)
	});
</script>